const jwt = require('jsonwebtoken')
module.exports = {
    async islogin(ctx, next) {
        const { token } = ctx.request.header
        try {
            const rudata = await jwt.verify(token, "ximo")
            ctx.id = rudata.id
            await next()
        } catch (error) {
            console.log(error)
            ctx.status = 401
            ctx.body = {
                code: 0,
                msg: 'token过期或未登录！'
            }
        }

    }
}